package com.example.featuresdk.navigation

import androidx.compose.ui.platform.LocalConfiguration
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.example.featuresdk.core.AbstractFeatureSDK
import com.example.featuresdk.view.SearchScreen
import com.example.featuresdk.view.SearchScreenConstraints
import com.example.featuresdk.viewmodel.SearchViewModel

fun NavGraphBuilder.sharedNestedNavigationGraph(navHostController: NavHostController, featureSDKs: List<AbstractFeatureSDK>) {

    NavigationController.instance.navController = navHostController
    NavigationController.instance.featureSDKs = featureSDKs

    navigation(startDestination = Screen.ROUTE_SEARCH.route, route = "app"){
        composable(route = Screen.ROUTE_SEARCH.route){

            val uiConstraints = SearchScreenConstraints().apply {init(LocalConfiguration.current) }
            val viewModel: SearchViewModel = hiltViewModel()
            SearchScreen(uiConstraints,viewModel.uiState,viewModel.commands)
        }
    }
}
